﻿using System;
using System.Text;
using SLS.ExClassLib.MultiThreading.Extensions;

namespace SLS.ExClassLib.MultiThreading.DataStructures.Dictionaries
{
    [Serializable]
    public struct KeyValuePairSerializable<TKey, TValue>
    {
        private TKey _key;
        private TValue _value;

        public KeyValuePairSerializable(TKey key, TValue value)
        {
            _key = key;
            _value = value;
        }

        /// <summary>
        /// Represent Value
        /// </summary>
        public TValue Value
        {
            get { return _value; }
            set { _value = value; }
        }

        /// <summary>
        /// Represent Key
        /// </summary>
        public TKey Key
        {
            get { return _key; }
            set { _key = value; }
        }

        public override string ToString()
        {
            var stringBuilder = new StringBuilder();
            stringBuilder.Append('[');
            if (Key.IsNotNull())
                stringBuilder.Append(Key.ToString());
            stringBuilder.Append(", ");
            if (_value.IsNotNull())
                stringBuilder.Append(Value.ToString());
            stringBuilder.Append(']');
            return stringBuilder.ToString();
        }
    }
}